<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <title>详情页</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <script src="__ROOT__/static/home/js/shop/rem.js"></script>
    <script type="text/javascript" src="__ROOT__/static/home/js/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="__ROOT__/static/plugins/layer.mobile-v2.0/layer_mobile/layer.js"></script>
    <link rel="stylesheet" type="text/css" href="__ROOT__/static/home/css/shop/base.css"/>
    <link rel="stylesheet" type="text/css" href="__ROOT__/static/home/css/shop/page.css"/>
    <link rel="stylesheet" type="text/css" href="__ROOT__/static/home/css/shop/all.css"/>
    <link rel="stylesheet" type="text/css" href="__ROOT__/static/home/css/shop/mui.min.css"/>
    <link rel="stylesheet" type="text/css" href="__ROOT__/static/home/css/shop/loaders.min.css"/>
    <link rel="stylesheet" type="text/css" href="__ROOT__/static/home/css/shop/loading.css"/>
    <link rel="stylesheet" type="text/css" href="__ROOT__/static/home/css/shop/slick/slick.css"/>
    <link rel="stylesheet" type="text/css" href="__ROOT__/static/home/css/shop/goodscats.css"/>
    <link rel="stylesheet" type="text/css" href="__ROOT__/static/plugins/bootstrap/css/bootstrap.css"/>
    <script type="text/javascript">
        $(window).load(function(){
            $(".loading").addClass("loader-chanage")
            $(".loading").fadeOut(300)
        })
    </script>
</head>
<!--loading页开始-->
<!--loading页结束-->
<body>
<!--header star-->
<header class="mui-bar mui-bar-nav" id="header">
    <a class="btn" href="javascript:history.go(-1);">
        <i class="iconfont icon-fanhui"></i>
    </a>
    <div class="top-sch-box top-sch-boxtwo flex-col">
        <ul>
            <li class="cur"><a href="#">商品</a></li>
        </ul>
    </div>
    <a class="btn" href="{:url('home/Cart/cartList')}">
        <i class="iconfont icon-gouwuche"></i>
        <span  id="cart_num">{$count}</span>
    </a>
</header>
<!--header end-->

<div class="warp warptwo clearfloat"  style="margin-top: 60px;" >
    <div class="detail clearfloat">
        <!--banner star-->
        <div class="banner swiper-container">
            <div class="swiper-wrapper">
                <div class="swiper-slide">
                    <a href="javascript:void(0)">
                        <img class="swiper-lazy" src="__ROOT__{$data['goods_url']}" alt="">
                    </a>
                </div>
            </div>
            <div class="swiper-pagination"></div>
        </div>
        <!--banner end-->
        <div class="top clearfloat box-s">
            <div class="shang clearfloat">
                <div class="zuo clearfloat fl over2 box-s">
                    {$data['goods_name']}
                </div>
                <div class="you clearfloat fr">
                    <i class="iconfont icon-fenxiang"></i>
                </div>
            </div>
            <div class="xia clearfloat">
                <p class="jifen fl box-s"><samp>单价:￥{$data['goods_price']}元</samp></p>
                <span class="fr">销量:{$data['initial_stock'] - $data['goods_stock']}</span>
            </div>
        </div>
        <!-- 商品数量加减-->
        <div class="goods_Number" >
            <button type="button" class="btn btn-default btn-sm"  onclick="reduce_num({$data['id']})" >
                <span class="glyphicon glyphicon-minus"></span>
            </button>
            <input type="text"  id="goods_num" onchange="changeGoodsNum()"
                   value="{$findCartInfo}"  style="width: 70px;height: 24px;text-align: center;" >
            <button type="button" class="btn btn-default btn-sm"  onclick="increase_num({$data['id']})">
                <span class="glyphicon glyphicon-plus"></span>
            </button>
        </div>

        <div class="middle clearfloat box-s">
            <a href="javascript:;">
                <span class="fl">商品详情:</span>
            </a>
        </div>
        <div  style="width: 100%;padding: 0 10px;color:#333333;font-size: 20px;">
            &nbsp;&nbsp;&nbsp;&nbsp;描述:
            <div>{$goodsInfoImages['goods_describe']}</div>
            <div  style="margin-top: 5px;" >
                {empty name="goodsInfoImages['goods_info_images1']"}{else /}<img src="__ROOT__{$goodsInfoImages['goods_info_images1']}"  style="width: 100%;height: 300px;"   />{/empty}<br>
                {empty name="goodsInfoImages['goods_info_images2']"}{else /}<img src="__ROOT__{$goodsInfoImages['goods_info_images2']}"  style="width: 100%;height: 300px;"   />{/empty}<br>
                {empty name="goodsInfoImages['goods_info_images3']"}{else /}<img src="__ROOT__{$goodsInfoImages['goods_info_images3']}"  style="width: 100%;height: 300px;"   />{/empty}<br>
                {empty name="goodsInfoImages['goods_info_images4']"}{else /}<img src="__ROOT__{$goodsInfoImages['goods_info_images4']}"  style="width: 100%;height: 300px;"   />{/empty}<br>
            </div>
        </div>
        <div class="middle clearfloat box-s">
            <a href="javascript:;">
                <span class="fl">商品评价:</span>
                <!--<i class="iconfont icon-jiantou1 fr"></i>-->
            </a>
        </div>
        <div  style="width: 100%;padding: 0 10px; color:#333333;font-size: 20px; ">
            &nbsp;&nbsp;评价:
            <div  style="margin-top: 5px;" >
                {volist  name='goodsInfoAppraises' id='appraises'  key='k' }
                <div   >
                {$appraises['appraise_content']}。
                </div>
                <div  style="text-align: right;"   >
                {:date('Y-m-d H:i:s',  $appraises['appraise_time'])}
                </div>
                {/volist}
            </div>
        </div>
    </div>
</div>

<!--footerone star-->
<div class="footerone clearfloat">
    <div class="right clearfloat fl" style="width:100%;font-size: 25px; " >
        <span class="btn fl"  style="width:19%;margin-right: 1%;color: #fff;font-size: 25px; ">
            <a  href="{:url('home/Shopping/index')}" style="color: #fff;">商城</a>
        </span>
        <span class="btn fl"  onclick="addCart({$data['id']},'{$data['goods_price']}')"  style="width:40%;font-size: 25px; ">
            加入购物车
        </span>

            <a href="javascript:;"   onclick="seeCart()"   style="color: #fff;">
                <span  class="btn btnone fl"   style="width:40%; color: #fff;font-size: 25px;" >
                查看购物车
                    </span>
            </a>

    </div>
</div>
<!--footerone end-->

<!--这里是弹出购物车内容-->


<!--footer star-->
<footer class="page-footer fixed-footer" id="footer">
    <ul>
        <li>
            <a href="{:url('home/Index/index')}">
                <i class="iconfont icon-shouye"></i>
                <p>首页</p>
            </a>
        </li>
        <li class="active">
            <a href="{:url('home/Goodscats/goodsCatsList')}">
                <i class="iconfont icon-icon04"></i>
                <p>分类</p>
            </a>
        </li>
        <li>
            <a href="javascript:;"   onclick="seeCart()">
                <i class="iconfont icon-gouwuche"></i>
                <p>购物车</p>
            </a>
        </li>
        <li>
            <a href="{:url('home/Userinfo/index')}">
                <i class="iconfont icon-yonghuming"></i>
                <p>个人中心</p>
            </a>
        </li>
    </ul>
</footer>
<!--footer end-->
</body>
<script>
    //查看购物车
    function seeCart(){
        $.post("{:url('home/Cart/seeCart')}",function(data){
            if( data >0){
                window.location.href="{:url('home/Cart/cartList')}";
            }else if( data==-1){
                layer.open({content: '请先登录用户',skin: 'msg',time: 3 });
                setTimeout('window.location.href="{:url(\'home/login/login\')}"',3000);
            }

        })
    }
    function addCart(id,shopPrice){
        var num = $('#goods_num').val();
        var params={};
        params.goodsId=id;
        params.shopPrice=shopPrice;
        params.num=num;
        $.post("{:url('home/Cart/addCart')}",params,function(data){
//			console.debug(data);
            if(data ==-1){
                layer.open({content: '该商品已添加过，请查看购物车',skin: 'msg',time: 3 });
                return;
            }else if(data == -2){
                layer.open({content: '请先登录用户',skin: 'msg',time: 3 });
                setTimeout('window.location.href="{:url(\'home/login/login\')}"',3000);
                return;
            }else if( data > 0){
                var cartnum = $('#cart_num').html();
                var cartnum2 = parseInt(cartnum)+1;
                $('#cart_num').html(cartnum2);
                layer.open({content: '添加成功，请查看购物车',skin: 'msg',time: 3 });
            }
        })
    }
    //减少数量
    function reduce_num(id){
        var num = $('#goods_num').val();
        if( num<=1  ){
            layer.open({content: '数量不能小于1，不能再减了',skin: 'msg',time: 3 });
            return;
        }
        $('#goods_num').val(num-1);
    }
    //增加数量
    function increase_num(id){
        var num = $('#goods_num').val();
        var num2 = parseInt(num)+1;
        $('#goods_num').val(num2);
    }
    function changeGoodsNum(id){
        var num = $('#goods_num').val();
        if(isNaN(num)){
            layer.open({content: '操作失败,必须是数字',skin: 'msg',time: 3 });
            return;
        }
        if( num<1  ){
            layer.open({content: '操作失败,数量不能小于1',skin: 'msg',time: 3 });
//            location.href="{:url('home/Cart/goodsInfo')}";
            return;
        }
        $('#goods_num').val(Math.round(num));
    }

</script>

</html>
